<template>
  <div >
    <el-table
      :data="tableData"
      style="width: 100%"
      :row-class-name="tableRowClassName">
      <el-table-column
        prop="id"
        label="编号"
        width="180">
      </el-table-column>
      <el-table-column
        prop="name"
        label="姓名"
        width="180">
      </el-table-column>
      <el-table-column
        prop="phone"
        label="手机号"
        width="180">
      </el-table-column>
      <el-table-column
        prop="email"
        label="邮箱"
        width="180">
      </el-table-column>
      <el-table-column
        prop="createTime"
        label="时间"
        width="180">
      </el-table-column>
      <el-table-column
        prop="address"
        label="地址">
      </el-table-column>
    </el-table>
    <el-pagination
      align="right"
      :page-size="pageSize"
      :current-page="currentPage"
      layout="prev, pager, next"
      :total="totals"
      @current-change="gotopage">

    </el-pagination>
  </div>
</template>


<script>
import axios from 'axios'
export default {

  data () {
    return {
      pageSize:5,
      currentPage:1,
      totals:0,
      tableData: []
    }
  },
  methods: {
    tableRowClassName({row, rowIndex}) {
      if (rowIndex === 1) {
        return 'warning-row';
      } else if (rowIndex === 3) {
        return 'success-row';
      }
      return '';
    },
    gotopage(goto){
  this.currentPage=goto
      this.pu()
    },
    pu(){
      this.$http.post("/user/list",{"currentPage":this.currentPage,"pageSize":this.pageSize})
        .then(result=>{
          this.tableData=result.data.rows
          this.totals=result.data.totals

        }).catch(result=>{
        alert("代码错误")
      })
    }
  },
  mounted() {
this.pu()
  }
}
</script>

<style>
.el-table .warning-row {
  background: oldlace;
}

.el-table .success-row {
  background: #f0f9eb;
}
</style>
